﻿@model WebApp.Models.BillHeader
@{
  ViewData["Title"] = "账单信息";
  ViewData["PageName"] = "BillHeaders_Index";
  ViewData["Heading"] = "<i class='fal fa-window text-primary'></i>  账单信息";
  ViewData["Category1"] = "账单管理";
  ViewData["PageDescription"] = "";
}
@section HeadBlock {
  <link href="@Fingerprint.Tag("/Scripts/plugin/jquery.fileuploader/jquery.fileuploader.min.css")" rel="stylesheet" />
  <link href="@Fingerprint.Tag("/Scripts/plugin/jquery.fileuploader/jquery.fileuploader-theme-dragdrop.css")" rel="stylesheet" />
  <link href="@Fingerprint.Tag("/Content/css/notifications/toastr/toastr.css")" rel="stylesheet" />
  <link href="@Fingerprint.Tag("/Scripts/easyui/themes/insdep/easyui.css")" rel="stylesheet" />
  <link href="@Fingerprint.Tag("/Content/css/formplugins/bootstrap-daterangepicker/bootstrap-daterangepicker.css")" rel="stylesheet" />
  <link href="~/Content/css/page-invoice.css" rel="stylesheet" />
}
<div class="row">
  <div class="col-lg-12 col-xl-12">
    <div id="panel-1" class="panel">
      <div class="panel-hdr">
        <h2>
          账单信息
        </h2>
        <div class="panel-toolbar">
          <button class="btn btn-panel bg-transparent fs-xl w-auto h-auto rounded-0" data-action="panel-collapse" data-toggle="tooltip" data-offset="0,10" data-original-title="Collapse"><i class="fal fa-window-minimize"></i></button>
          <button class="btn btn-panel bg-transparent fs-xl w-auto h-auto rounded-0" data-action="panel-fullscreen" data-toggle="tooltip" data-offset="0,10" data-original-title="Fullscreen"><i class="fal fa-expand"></i></button>
          @*<button class="btn btn-panel bg-transparent fs-xl w-auto h-auto rounded-0" data-action="panel-close" data-toggle="tooltip" data-offset="0,10" data-original-title="Close"><i class="fal fa-trash-alt"></i></button>*@
        </div>

      </div>
      <div class="panel-container enable-loader show">
        <div class="loader"><i class="fal fa-spinner-third fa-spin-4x fs-xxl"></i></div>
        <div class="panel-content py-2 rounded-bottom border-faded border-left-0 border-right-0  text-muted bg-faded bg-subtlelight-fade">
          <div class="row no-gutters align-items-center">
            <div class="col">
              <!-- 开启授权控制请参考 @@if (Html.IsAuthorize("Create") -->
              <div class="btn-group btn-group-sm">
                <button name="searchbutton" class="btn btn-default"> <span class="fal fa-search mr-1"></span> @Html.L("Refresh") </button>
              </div>
              <div class="btn-group btn-group-sm">
                <button name="appendbutton" class="btn btn-primary"> <span class="fal  fa-plus mr-1"></span> 生成账单 </button>
              </div>
              <div class="btn-group btn-group-sm">
                <button name="checkinbutton" class="btn btn-success"> <span class="fal  fa-check-square mr-1"></span> 账单确认 </button>
              </div>
              <div class="btn-group btn-group-sm">
                <button name="printbutton" class="btn btn-info"> <span class="fal  fa-print mr-1"></span> 打印账单 </button>
              </div>
              <div class="btn-group btn-group-sm">
                <button name="sendbutton" class="btn btn-success"> <span class="fal  fal fa-mail-bulk mr-1"></span> 发送电子账单 </button>
              </div>
              <div class="btn-group btn-group-sm">
                <button name="deleterowbutton" disabled class="btn btn-default"> <span class="fal fa-trash-alt mr-1"></span> @Html.L("Delete") </button>
              </div>

              <div class="btn-group btn-group-sm hidden-xs">
                <button name="importexcelbutton" type="button" class="btn btn-default"><span class="fal fa-cloud-upload mr-1"></span> @Html.L("Import") </button>
                <button type="button" class="btn btn-default dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  <span class="sr-only">Toggle Dropdown</span>
                </button>
                <div class="dropdown-menu">
                  <button name="downloadtemplatebutton" class="dropdown-item js-waves-on"><span class="fal fa-download"></span> @Html.L("Download") </button>
                </div>
              </div>
              <div class="btn-group btn-group-sm ">
                <button name="exportexcelbutton" class="btn btn-default"> <span class="fal fa-file-excel mr-1"></span>  @Html.L("Export") </button>
              </div>
              <div class="btn-group btn-group-sm ">
                <button name="helpbutton" class="btn btn-default"> <span class="fal fa-question-circle mr-1"></span> @Html.L("Help") </button>
              </div>
            </div>
          </div>
        </div>
        <div class="panel-content">
          <div class="table-responsive">
            <table id="billheaders_datagrid">
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- Modal center Small -->
<div class="modal fade" id="default-example-modal-sm-center" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">选择月份</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true"><i class="fal fa-times"></i></span>
        </button>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label class="form-label text-muted" for="inputmonth">选择要生成账单的月份</label>
          <select class="form-control" id="inputmonth">
          </select>
        </div>
        <div class="form-group">
          <label class="form-label text-muted" for="endday">截至日</label>
          @Html.DropDownList("endday", (IEnumerable<SelectListItem>)ViewBag.endday, new { @class = "form-control" })
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" onclick="createbill()">生成账单</button>
      </div>
    </div>
  </div>
</div>


@section ScriptsBlock {
  @{ Html.RenderPartial("_ImportWindow", new ViewDataDictionary { { "EntityName", "BillHeader" } }); }
  @{ Html.RenderPartial("_PopupDetailFormView", new WebApp.Models.BillHeader()); }
  <script src="~/Scripts/dependency/moment/moment.js"></script>
  <script src="~/Scripts/plugin/numeral/numeral.min.js"></script>
  <script src="~/Scripts/plugin/jquery.fileuploader/jquery.fileuploader.min.js"></script>
  <script src="@Fingerprint.Tag("/Scripts/notifications/toastr/toastr.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/formplugins/bootstrap-daterangepicker/bootstrap-daterangepicker.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/easyui/jquery.easyui.min.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/easyui/plugins/datagrid-filter.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/easyui/locale/easyui-lang-zh_CN.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/jquery.easyui.component.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/jquery.extend.formatter.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/jquery.custom.extend.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/plugin/jquery.serializejson/jquery.serializejson.min.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/plugin/filesaver/FileSaver.min.js")"></script>
  <script src="@Fingerprint.Tag("/Scripts/plugin/filesaver/jquery.fileDownload.js")"></script>
  <script type="text/javascript">
    function initmonthoptions() {
      for (let i = 0; i < 24; i++) {
        var dt = moment().add(-i, 'M');
        var item = {
          value: moment(dt).format('YYYY-MM'),
          text: moment(dt).format('YYYY年MM月'),
        };
        $('#inputmonth').append($('<option>', {
          value: item.value,
          text: item.text
        }));
      }
    }
    initmonthoptions();
    $('button[name="sendbutton"]').on('click', () => { sendbilltocustomer() });

    $('button[name="printbutton"]').on('click', () => { printbill() });
    //打印账单
    function printbill() {
      var selected = $dg.datagrid('getChecked').filter(item => item.Status == '已确认');
      if (selected.length > 0) {
        var id = selected.map(item => item.Id);
        const url = '/BillHeaders/PrintPreview?selectid=' + id.toString();
        window.open(url, '_blank').focus();
        //let formData = new FormData();
        //formData.append('id', id);
        //$.postDownload('/BillHeaders/PrintBill', formData).then(res => {
        //    toastr.success('下载完成!');
        //}).catch(err => {
        //  $.messager.alert('下载失败', err.statusText, 'error');
        //});
      } else {
        bootbox.alert("请选择【已确认】的账单")
      }
    }

    //发送电子账单
    function sendbilltocustomer() {
      var selected = $dg.datagrid('getChecked').filter(item => item.Status == '已确认');
      if (selected.length > 0) {
        if (selected.filter(item => item.HasSend).length > 0) {
          var id = selected.map(item => item.Id);
          bootbox.confirm("该账单已经发送过,你确定要重发吗?", function (result) {
            if (result) {
              $.messager.progress({
                title: '请耐心等待',
                msg: '正在发送电子账单给客户'
              });
              $.post('/BillHeaders/SendToCustomer', { id }).done(res => {
                $.messager.progress('close');
                if (res.success) {
                  reloadData();
                }
                else {
                  $.messager.alert('异常', res.err);
                }
               
              })
            }
          })
        } else {
          var id = selected.map(item => item.Id);
          $.messager.progress({
            title: '请耐心等待',
            msg: '正在发送电子账单给客户'
          });
          $.post('/BillHeaders/SendToCustomer', { id }).done(res => {
            $.messager.progress('close');
            if (res.success) {
              reloadData();
            }
            else {
              $.messager.alert('异常', res.err);
            }
          })
        }
      } else {
        bootbox.alert("请选择【已确认】的账单")
      }
    }
    //生成账单
    function createbill() {
      $.messager.progress({
        title: '请耐心等待',
        msg:'系统正在收集数据.....'
      });
      var month = $('#inputmonth').val();
      var day = $('#endday').val();
      console.log(month, day)
      $.get('/BillHeaders/GenerateBills?month=' + month + '&day=' + day).done(res => {
        $.messager.progress('close');
        if (res.success) {
          $.messager.alert('提示', '账单生成成功.');
          $('#default-example-modal-sm-center').modal('toggle');
          reloadData();
        } else {
          $.messager.alert('错误', res.err,'error');
        }

      })


    }
    //绑定按钮事件
    $('button[name="searchbutton"]').on('click', () => { reloadData() });
    //修改状态
    $('button[name="checkinbutton"]').on('click', () => {
      var id = $dg.datagrid('getChecked').filter(item => item.Status == '待确认').map(item => item.Id);
      if (id.length > 0) {
        bootbox.confirm("账单一旦确认就不允许修改?", function (result) {
          if (result) {
            
            $.post('/BillHeaders/Confirm', { id }).done(res => {
              reloadData();
            })
          }
        })
      } else {
        bootbox.alert("请选择待确认的账单")
      }

    });

    $('button[name="appendbutton"]').on('click', () => {
      $('#default-example-modal-sm-center').modal('toggle')

    });
    $('button[name="deleterowbutton"]').on('click', deleteRow);
    $('button[name="exportexcelbutton"]').on('click', exportExcel);
    $('button[name="importexcelbutton"]').on('click', () => {
      importexcel('BillHeader')
    });
    $('button[name="downloadtemplatebutton"]').on('click', () => {
      downloadtemplate('BillHeader')
    });
    //全屏事件
    document.addEventListener('panel.onfullscreen', () => {
         $dg.datagrid('resize');
     });
      //是否强制从后台取值
      const REQUIRBACKEND = false;
      //是否开启行内编辑
      const EDITINLINE = false;
      var billheader = {};

       //执行导出下载Excel
       function exportExcel() {
                const filterRules = JSON.stringify($dg.datagrid('options').filterRules);
                //console.log(filterRules);
                const dialog = bootbox.dialog({
                    message: '<div class="text-center"><i class="fal fa-spinner fa-pulse fa-lg mr-1"></i> 正在执行...</div>',
                    closeButton: false
                 });
                let formData = new FormData();
                formData.append('filterRules', filterRules);
                formData.append('sort', 'Id');
                formData.append('order', 'asc');
                $.postDownload('/BillHeaders/ExportExcel', formData).then(res => {
                    setTimeout(() => {
                       dialog.modal('hide')
                     }, 300);
                    toastr.success('导出成功!');
                }).catch(err => {
                    setTimeout(() => {
                       dialog.modal('hide')
                     }, 300);
                    $.messager.alert('导出失败', err.statusText, 'error');
                });

        }
        //显示帮助信息
        function dohelp() {
            toastr.info('有问题请联系管理员 <br><i class="fa fa-envelope-o" aria-hidden="true"></i> : demo@admin.com','帮助');
        }
       var editIndex = undefined;
       //重新加载数据
       function reloadData() {
            $dg.datagrid('unselectAll');
            $dg.datagrid('uncheckAll');
            $dg.datagrid('reload');
       }
    //新增记录
    async function appendData() {
       billheader = { CustomerId: null,
CustomerName: null,
WaterPrice: 0,
ServicePrice: 0,
Discount: 0,
BillDate: moment().format('YYYY-MM-DD HH:mm:ss'),
ReceiptDate: null,
TotalWater: 0,
TotalWaterAmount: 0,
TotalServiceAmount: 0,
AdjustWater: 0,
AdjustWaterAmount: 0,
AdjustServiceAmount: 0,
TotalAmount: 0,
TotalReceivableAmount: 0,
 };
        //需要后台创建对象
       if (REQUIRBACKEND) {
         billheader = await $.get('/BillHeaders/NewItem');
       }
           //弹出新增窗口
           openbillheaderdetailwindow(billheader, 'Added');
    }
    //删除编辑的行
    function deleteRow() {
    deleteChecked();
    }
    //删除选中的行
    function deleteChecked() {
      const checked = $dg.datagrid('getChecked').filter(item => item.Status =='待确认').map(item => {
        return item.Id;
      });;
      if (checked.length > 0) {
        deleteRows(checked);
      } else {
        $.messager.alert('提示', '请先选择【待确认】的记录!', 'question');
      }
    }
    //执行删除
    function deleteRows(selected){
      $.messager.confirm('确认', `你确定要删除这 <span class='badge badge-icon position-relative'>${selected.length} </span> 行记录?`, result => {
       if (result) {
         $.post('/BillHeaders/DeleteChecked', { id: selected })
                         .done(response => {
                                if (response.success) {
                                    toastr.error(`成功删除 [${selected.length}] 行记录`);
                                    reloadData();
                                } else {
                                    $.messager.alert('错误', response.err,'error');
                                }
                          })
                          .fail((jqXHR, textStatus, errorThrown) => {
                             $.messager.alert('异常', `${jqXHR.status}: ${jqXHR.statusText} `, 'error');
                          });
        }
      });
    }
    //弹出明细信息
    async function showdetailsWindow(id,index) {
        const billheader = $dg.datagrid('getRows')[index];
        if (REQUIRBACKEND) {
           billheader = await $.get('/BillHeaders/GetItem/' + id);
        }
        openbillheaderdetailwindow(billheader,'Modified');
    }

    //初始化定义datagrid
    var $dg = $('#billheaders_datagrid');
    $(() => {
      //定义datagrid结构
      $dg.datagrid({
        //fit: false,
       height:670,
        rownumbers: true,
        checkOnSelect: false,
        selectOnCheck: false,
        idField: 'Id',
        sortName: 'Id',
        sortOrder: 'desc',
        remoteFilter: true,
        singleSelect: true,
        //url: '/BillHeaders/GetData',
        method: 'post',
        pagination: true,
        clientPaging: false,
        striped: true,
        pageSize:15,
        pageList: [15, 20, 50, 100, 500, 2000],
        filterRules: [],
        onBeforeLoad: function () {
          $('.enable-loader').removeClass('enable-loader')
        },
        onLoadSuccess: function (data) {
          $("button[name*='deleterowbutton']").prop('disabled', true);
        },
        onCheck: function () {
          $("button[name*='deleterowbutton']").prop('disabled', false);
        },
        onUncheck: function () {
          const checked = $(this).datagrid('getChecked').length > 0;
          $("button[name*='deleterowbutton']").prop('disabled', !checked);
        },
        onCheckAll: function (rows) {
          if (rows.length > 0) {
            $("button[name*='deleterowbutton']").prop('disabled', false);
          }
        },
        onUncheckAll: function () {
          $("button[name*='deleterowbutton']").prop('disabled', true);
        },
        onSelect: function (index, row) {
          billheader = row;
        },
        frozenColumns: [[
          /*开启CheckBox选择功能*/
          { field: 'ck', checkbox: true },
          {
            field: 'action',
            title: '@Html.L("Command")',
            align: 'center',
            width: 85,
            sortable: false,
            resizable: true,
            formatter: function showdetailsformatter(value, row, index) {
                   return `<div class="btn-group">\
                     <button onclick="showdetailsWindow('${row.Id}',  ${index})" class="btn btn-outline-info btn-sm btn-icon waves-effect waves-themed" data-toggle="tooltip" data-placement="right" title="@Html.L("EditDetail")" ><i class="fal fa-list"></i> </button>
                     <a href="/BillHeaders/Details/${row.Id}" target="_blank" class="btn btn-outline-info btn-sm btn-icon waves-effect waves-themed"><i class="fal fa-envelope-open-dollar"></i></a>
                    </div>
                      `;
              
            }
          }
        ]],
        columns: [[
          {    /*状态*/
            field: 'Status',
            title: '@Html.DisplayNameFor(model => model.Status)',
            width: 100,
            align: 'right',
            hidden: false,
            formatter: statusformatter
          },
          {    /*月份*/
            field: 'Month',
            title: '@Html.DisplayNameFor(model => model.Month)',
            width: 120,
            hidden: false,
            sortable: true,
            resizable: true
          },
          {    /*账单编号*/
            field: 'BillNo',
            title: '@Html.DisplayNameFor(model => model.BillNo)',
            width: 100,
            hidden: false,
            sortable: true,
            resizable: true
          },
          {    /*单位名称*/
            field: 'CustomerCode',
            title: '@Html.DisplayNameFor(model => model.CustomerCode)',
            width: 120,
            hidden: false,
            sortable: true,
            resizable: true
          },
          {    /*单位名称*/
            field: 'CustomerName',
            title: '@Html.DisplayNameFor(model => model.CustomerName)',
            width: 200,
            hidden: false,
            sortable: true,
            resizable: true
          },
          {    /*客户类型*/
            field: 'Category',
            title: '@Html.DisplayNameFor(model => model.Category)',
            width: 200,
            hidden: false,
            sortable: true,
            resizable: true
          },
          {   /*账单日期*/
            field: 'BillDate',
            title: '@Html.DisplayNameFor(model => model.BillDate)',
            width: 110,
            align: 'right',
            hidden: false,
            formatter: dateformatter,
            sortable: true,
            resizable: true
          },
          {   /*账单日期*/
            field: 'PaymentDate',
            title: '@Html.DisplayNameFor(model => model.PaymentDate)',
            width: 110,
            align: 'right',
            hidden: false,
            formatter: dateformatter,
            sortable: true,
            resizable: true
          },
          {   /*收费日期*/
            field: 'ReceiptDate',
            title: '@Html.DisplayNameFor(model => model.ReceiptDate)',
            width: 110,
            align: 'right',
            hidden: false,
            formatter: dateformatter,
            sortable: true,
            resizable: true
          },
          {    /*水单价(元/m3)*/
            field: 'WaterPrice',
            title: '@Html.DisplayNameFor(model => model.WaterPrice)',
            width: 100,
            align: 'right',
            hidden: false,
            sortable: true,
            resizable: true
          },
          {    /*折扣*/
            field: 'Discount',
            title: '@Html.DisplayNameFor(model => model.Discount)',
            width: 100,
            align: 'right',
            hidden: false,
            formatter: numberformatter,
            sortable: true,
            resizable: true
          },
         {    /*总水量(m3)*/
            field: 'TotalWater',
            title: '@Html.DisplayNameFor(model => model.TotalWater)',
            width: 100,
            align: 'right',
            hidden: false,
            formatter: numberformatter,
            sortable: true,
            resizable: true
          },
          {    /*上个月总用水量(m3)*/
            field: 'LastTotalWater',
            title: '@Html.DisplayNameFor(model => model.LastTotalWater)',
            width: 160,
            align: 'right',
            hidden: false,
            formatter: numberformatter,
            sortable: true,
            resizable: true
          },
          {    /*环比(%)*/
            field: 'PerCent',
            title: '@Html.DisplayNameFor(model => model.PerCent)',
            width: 100,
            align: 'right',
            hidden: false,
            formatter: function (result) {
              if (result != null) {
                if (result > 0) {
                  return `<span class="badge badge-success">${result} % </span>`
                } else {
                  return `<span class="badge badge-danger">${result} % </span>`
                }
              } else {
                return ''
              }

            },
            sortable: true,
            resizable: true
          },
          {    /*总水价(元)*/
            field: 'TotalWaterAmount',
            title: '@Html.DisplayNameFor(model => model.TotalWaterAmount)',
            width: 100,
            align: 'right',
            hidden: false,
            formatter: numberformatter,
            sortable: true,
            resizable: true
          },
          {    /*补扣水量(m3)*/
            field: 'AdjustWater',
            title: '@Html.DisplayNameFor(model => model.AdjustWater)',
            width: 100,
            align: 'right',
            hidden: false,
            formatter: numberformatter,
            sortable: true,
            resizable: true
          },
          {    /*补扣水费(元)*/
            field: 'AdjustWaterAmount',
            title: '@Html.DisplayNameFor(model => model.AdjustWaterAmount)',
            width: 100,
            align: 'right',
            hidden: false,
            formatter: numberformatter,
            sortable: true,
            resizable: true
          },

          {    /*总费用(元)*/
            field: 'TotalAmount',
            title: '@Html.DisplayNameFor(model => model.TotalAmount)',
            width: 100,
            align: 'right',
            hidden: false,
            formatter: numberformatter,
            sortable: true,
            resizable: true
          },
          {    /*总应收费用(元)*/
            field: 'TotalReceivableAmount',
            title: '@Html.DisplayNameFor(model => model.TotalReceivableAmount)',
            width: 150,
            align: 'right',
            hidden: false,
            formatter: numberformatter,
            sortable: true,
            resizable: true
          },
          {    /*总应收费用(元)*/
            field: 'HasSend',
            title: '@Html.DisplayNameFor(model => model.HasSend)',
            width: 120,
            align: 'right',
            hidden: false,
            formatter: checkboxformatter,
            sortable: true,
            resizable: true
          },
          {    /*备注*/
            field: 'Remark',
            title: '@Html.DisplayNameFor(model => model.Remark)',
            width: 260,
            hidden: false,
            sortable: true,
            resizable: true
          },
        ]]
      }).datagrid('enableFilter', [
        /*需要在键值队维护好status枚举值*/
        {  /*状态*/
          field: 'Status',
          type: 'bstatusfilter',
          options: {

          }
        },
        {  /*状态*/
          field: 'Month',
          type: 'combobox',
          options: {
            url: '/BillHeaders/GetMonthDataSource',
            panelHeight: 'auto',
            valueField: 'value', textField: 'text',
            editable: false,
            getValue: function () {
              return ''
            },
            onChange: value => {
              if (value == '' || value=='All') {
                $dg.datagrid('removeFilterRule', 'Month');

              } else {
                $dg.datagrid('addFilterRule', {
                  field: 'Month',
                  op: 'equal',
                  value: value
                });
               
              }
              $dg.datagrid('doFilter');
              //
            }
          }
        },
        {  /*状态*/
          field: 'Category',
          type: 'categoryfilter',
          options: {
            
          }
        },
        {   /*水单价(元/m3)*/
          field: 'WaterPrice',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*水服务费单价(元/m3)*/
          field: 'ServicePrice',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*折扣*/
          field: 'Discount',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*总水量(m3)*/
          field: 'TotalWater',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*上个月总用水量(m3)*/
          field: 'LastTotalWater',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*环比(%)*/
          field: 'PerCent',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*总水价(元)*/
          field: 'TotalWaterAmount',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*总水服务费(元)*/
          field: 'TotalServiceAmount',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*补扣水量(m3)*/
          field: 'AdjustWater',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*补扣水费(元)*/
          field: 'AdjustWaterAmount',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*补扣服务费(元)*/
          field: 'AdjustServiceAmount',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*总费用(元)*/
          field: 'TotalAmount',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {   /*总应收费用(元)*/
          field: 'TotalReceivableAmount',
          type: 'numberbox',
          op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
        },
        {     /*账单日期*/
          field: 'BillDate',
          type: 'dateRange',
          options: {
          }
        },
        {     /*收费日期*/
          field: 'ReceiptDate',
          type: 'dateRange',
          options: {
          }
        },

      ])
        .datagrid('load', '/BillHeaders/GetData');

    });

  </script>



  <!-- billdetail datagrid  javascript block -->
  @Html.Partial("_billdetaildatagridjsview", new WebApp.Models.BillDetail())
  <!--end popup detailview javascript block -->
}


